import http from '@/utils/http'
import { useAuthStore } from '@/store/auth'
import { storeToRefs } from 'pinia'

const authStore = useAuthStore()
const { globalParams } = storeToRefs(authStore)

// 获取巷道模型数据
export interface WireData {
  baseInfo: BaseInfo
  wireItems: WireItem[]
  customerNo: string
}
export function getModelData () {
  return http.get('/tunnel/tunnelModel', {
    params: {
      ...globalParams.value
    }
  })
}
// 获取区域列表
export const getAreaList = (search) => {
  if (search) {
    return http.postOrJson('/area/areaList', { ...globalParams.value, ...search })
  }
  return http.postOrJson('/area/areaList', { ...globalParams.value })
}


// 获取采面工作面详情
export const getCmEngInfoById = (engId: string) => {
  return http.postOrJson(`/area/cmEngInfoById?engId=${engId}`)
}

// 获取掘进工作面详情
export const getJjEngInfoById = (engId: string) => {
  return http.postOrJson(`/area/jjEngInfoById?engId=${engId}`)
}

// 根据区域id获取巷道id
export const getTunnelIdByAreaId = (areaId: string) => {
  return http.get('/tunnel/getTunnelIdByAreaId', {
    params: {
      ...globalParams.value,
      areaId
    }
  })
}
// 根据巷道id获取区域id
export const getAreaIdByTunnelId = (areaId: string) => {
  return http.get('/tunnel/getAreaIdByTunnelId', {
    params: {
      ...globalParams.value,
      areaId
    }
  })
}

// 根据cdCode获取区域信息
export const getEngInfoByCdCode = (cdCode: string) => {
  return http.get('/area/getEngInfoByCdCode', {
    params: {
      ...globalParams.value,
      cdCode
    }
  })
}

// 根据区域id获取巷道列表
export const getJzListByAreaId = () => {
  return http.get('/tunnel/getJzListByAreaId', {
    params: {
      ...globalParams.value
    }
  })
}
